
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList,
                 com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.users.User"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/addNewShipper.do"/>

<html:html locale="true">

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<script language='javascript'>
function save()
{
    var errors = '';
    var shipper = document.shipperForm.shipperName.value;
    if( shipper.value != '' )
    {
        if( shipper.trim().length == 0 )
        {
            errors = errors + "<li> Please enter shipper Name";
        }
    }
    if( errors != '' )
    {
        var inf = document.getElementById( "infoMessagesId" );
        inf.innerHTML = '';
        var err = document.getElementById("errorMessagesId");
        err.innerHTML = '';
        var pa=document.getElementById("errors");
        pa.innerHTML = errors;
        return false;
    }
    var oldshipper = document.shipperForm.oldShipper.value;
    if ( oldshipper == '' )
    {
        document.shipperForm.action = '<%=chipTracContext%>/addNewShipper.do?action=insertShipper';
    }
    else
    {
        document.shipperForm.action = '<%=chipTracContext%>/addNewShipper.do?action=editShipper';
    }
    return true;
}
function reset(){
    document.shipperForm.reset();
}
function closeWindow(form) {
    window.opener.document.shipperForm.submit();
 	window.close();
}
function loadshipper( shipperName )
{
    document.shipperForm.shipperName.value = shipperName;
    document.shipperForm.oldShipper.value = shipperName;
    var inf = document.getElementById("infoMessagesId");
    inf.innerHTML = '';
    var err = document.getElementById("errorMessagesId");
    err.innerHTML = '';
}
function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}
</script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<html:form name="shipperForm" type="com.scalar.chiptrack.sales.forms.shipperForm" action='/addNewShipper.do?action=insertshipper' onsubmit="javascript:return save();" scope="request">
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
<center><span class="NArialW">shipper</span></center>
<table border="0" width="90%" align=center>
 <tr><td>
 <table border="0" width="100%" cellspacing='10' cellpadding='2' align='center'>
 <tr><td colspan=2 align=right><a href="javascript:closeWindow(document.shipperForm);" onMouseOver="window.status='Click here to close this window';return true" onmouseout="window.status='';return true" ><font class='NArialL'>Close this window</font></a></td></tr>
 <tr><td colspan='2' id='errorMessagesId'><chiptrack:errors styleClass='NArialL' /></td></tr>
 <tr><td colspan='2' id='infoMessagesId'><chiptrack:info styleClass='NArialL' /> </td></tr>
 <tr><td colspan='2' align="left" class='NArialL'><FONT id="errors" styleClass="NArialL" color='FF0000'></FONT></TD></TR>
	<tr>
        <td colspan='2' nowrap><font class="NArialL">shipper Name:<font color=red>*</font>&nbsp;&nbsp;</font>
			<html:text property="shipperName" size="25" maxlength="25" styleClass="txfield"/>
            <input type="hidden" name="oldShipper" value="">
		</td>
    </tr>
	<tr>
        <td colspan='1' nowrap align='center'>
             <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Save shipper';return true" onmouseout="window.status='';return true" title="Click here to Save shipper">
	    </td>
		<td colspan='1' nowrap align='left'>
		     <a href="javascript:reset()" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a>
	    </td>
    </tr>
  </table>
  </td></tr>
  <tr><td>
<!-- DISPLAY ALL SHIPPERS STARTS HERE -->

<% ArrayList shippers = (ArrayList) request.getAttribute("shippers");
	if( shippers != null && shippers.size() != 0 ) { %>

   <table border="0" width="100%" bordercolor="#FFFFFF" align='center'>
    <tr>
        <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">shipper </font></font></td>
        <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Action</font></font></td>
    </tr>

    <% int bgcount = 0;%>
    <logic:iterate id="shipper" name="shippers" type="com.scalar.chiptrack.operations.vendor.Shipper">
    <% bgcount = bgcount + 1; %>
    <tr>
    <td nowrap width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
    <bean:write name="shipper" property="shipperName" /></font></td>
    <td nowrap width="15%" align="center" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
     <logic:equal name="shipper" property="disabled" value="true">
     <a href='<%=chipTracContext%>/addNewShipper.do?shipperstatus=disable&shipper=<bean:write name="shipper" property="encodeShipper" />&shipperId=<bean:write name="shipper" property="shipperId" />'>Disable</a>&nbsp;&nbsp;
     </logic:equal>
     <logic:equal name="shipper" property="disabled" value="false">
     <a href='<%=chipTracContext%>/addNewShipper.do?shipperstatus=activate&shipper=<bean:write name="shipper" property="encodeShipper" />&shipperId=<bean:write name="shipper" property="shipperId" />' ><font color='red'> Activate</font></a>&nbsp;
     </logic:equal>
     <a href="javascript:loadshipper('<bean:write name="shipper" property="shipperName" />');" onMouseOver="window.status='Click to Edit shipper';return true" onmouseout="window.status='';return true">Edit</a>
     </font></td>

    </tr>
    </logic:iterate>

    <tr><td class="NArialL" colspan=5><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=50></td></tr>
    <tr><td colspan=3 align=center><a href="javascript:closeWindow(document.shipperForm);" onMouseOver="window.status='Click here to close this window';return true"><font class='NArialL'>Close this window</font></a></td></tr>

    </table>
	<% } %>
<!-- DISPLAY ALL SHIPPERS ENDS HERE -->
</td></tr>
</table>
<input type="hidden" name="vendorId" value ='<%=request.getParameter("vendorId")%>' >
</html:form>
</body>
</html:html>